﻿using MaterialDesignThemes.Wpf;
using Prism.Events;
using Prism.Regions;
using Sigma.Admin.Client.Extensions;
using Sigma.Admin.Client.ViewModels;
using Sigma.Admin.Client.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Sigma.Admin.Client
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow(IEventAggregator aggregator)
        {
            InitializeComponent();
            //给消息提示控件的消息队列注册事件聚合器，事件发布后会被队列接收
            aggregator.ResgiterMessage(arg =>
            {
                SnakeBar.MessageQueue.Enqueue(arg);
            });
            //注册等待消息窗口
            aggregator.Resgiter(arg =>
            {
                DialogHost.IsOpen = arg.IsOpen;

                if (DialogHost.IsOpen)
                    DialogHost.DialogContent = new ProgressView();
            });
        }

        //// Create a custom routed event by first registering a RoutedEventID
        //// This event uses the bubbling routing strategy
        //public static readonly RoutedEvent EnterEvent = EventManager.RegisterRoutedEvent(
        //    "KeyEnter", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(MainWindow));

        //public static readonly RoutedEvent EscEvent = EventManager.RegisterRoutedEvent(
        //    "KeyEsc", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(MainWindow));

        
        //public event RoutedEventHandler Enter
        //{
        //    add { AddHandler(EnterEvent, value); }
        //    remove { RemoveHandler(EnterEvent, value); }
        //}

        //public event RoutedEventHandler Esc
        //{
        //    add { AddHandler(EscEvent, value); }
        //    remove { RemoveHandler(EscEvent, value); }
        //}
        //// This method raises the Tap event
        //void RaiseEnterEvent()
        //{
        //    RoutedEventArgs newEventArgs = new RoutedEventArgs(MainWindow.EnterEvent);
        //    RaiseEvent(newEventArgs);
        //}
        //void RaiseEscEvent()
        //{
        //    RoutedEventArgs newEventArgs = new RoutedEventArgs(MainWindow.EscEvent);
        //    RaiseEvent(newEventArgs);
        //}
        //// For demonstration purposes we raise the event when the MyButtonSimple is clicked
        //protected override void OnKeyUp(KeyEventArgs e)
        //{
        //    base.OnKeyUp(e);
            
        //    if (e.Key == Key.Enter)
        //    {
        //        RaiseEnterEvent();
        //    }
        //    if (e.Key == Key.Escape)
        //    {
        //        RaiseEscEvent();
        //    }

        //}
       
    }
}
